﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wedn.Core.Common;
using Wedn.Core.Entity;
using Wedn.Core.Service;
using Wedn.Core.Utility;

namespace Wedn.Web.UI.Admin.Include
{
    public partial class Posts : AdminInclude
    {
        protected int allCount, publicCount, draftCount, recycleCount;

        protected void Page_Load(object sender, EventArgs e)
        {
            //PostManager postManager = new PostManager();
            ////页面显示条数
            //int pageSize = 16;
            ////当前页码
            //int pageIndex = RequestHelper.QueryInt("page", 1);
            ////获取参数
            //string status = RequestHelper.QueryString("status", true);
            //PostStatus postStatus = PostStatus.Default;
            //switch (status)
            //{
            //    case "public":
            //        postStatus = PostStatus.Pubilc;
            //        break;
            //    case "draft":
            //        postStatus = PostStatus.Draft;
            //        break;
            //    case "recycle":
            //        postStatus = PostStatus.Recycle;
            //        break;
            //}
            //List<Post> postList = postManager.GetPostList(null, postStatus, PostType.Post, -1, -1, null, null, pageSize, pageIndex, "post_id", 0, out allCount);
            ////draftCount = postList.FindAll(p => { return p.Type == "draft"; }).Count;
            ////recycleCount = postList.FindAll(p => { return p.Type == "recycle"; }).Count;
            //publicCount = allCount - draftCount - recycleCount;
            //repPosts.DataSource = postList;
            //repPosts.DataBind();

        }
        protected void SubNav()
        {
            StringBuilder sbd = new StringBuilder();
            sbd.AppendFormat("<li class=\"all\"><a href=\"?status=all\">全部 <span class=\"count\">({0})</span></a> |</li>", publicCount);
            if (publicCount > 0)
                sbd.AppendFormat("<li class=\"public\"><a href=\"?status=public\">已发布 <span class=\"count\">({0})</span></a> |</li>", publicCount);
            if (draftCount > 0)
                sbd.AppendFormat("<li class=\"draft\"><a href=\"?status=draft\">草稿 <span class=\"count\">({0})</span></a> |</li>", draftCount);
            if (recycleCount > 0)
                sbd.AppendFormat("<li class=\"recycle\"><a href=\"?status=recycle\">回收站 <span class=\"count\">({0})</span></a></li>", draftCount);

            Response.Write(sbd.ToString());
        }
        protected void PagedLink()
        {
            string str = Paged(allCount, 16);
            Response.Write(str);
        }
    }
}